-
Notifications
You must be signed in to change notification settings - Fork 33
chore: clean up the logic of greeter and lockscreen #735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @calsys456, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request cleans up and refactors the greeter and lockscreen logic in Treeland, making the code more maintainable and robust. The PR integrates with systemd-logind for lock/unlock signals and centralizes greeter state management in the GreeterProxy singleton.
Changes:
- Refactored GreeterProxy to be a comprehensive singleton managing all greeter/lockscreen state with proper DBus signal listeners for systemd-logind session Lock/Unlock events
- Renamed "logined" to "loggedIn" throughout the codebase for correct English naming
- Removed the QML GreeterModel singleton and simplified QML component structure, eliminating the WallpaperController.ScaleWithoutAnimation state in favor of conditional animation enablement
- Updated SessionModel to track currentIndex as a property instead of lastIndex, simplifying session selection
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/greeter/greeterproxy.h | Complete rewrite with extensive documentation, new properties (isLocked, failedAttempts, showShutdownView, showAnimation, hasActiveSession), and QDBusContext integration |
| src/greeter/greeterproxy.cpp | Refactored implementation with systemd-logind signal listeners (SessionNew, SessionRemoved, Lock, Unlock), centralizing lock/unlock logic |
| src/greeter/sessionmodel.h | Changed from lastIndex to currentIndex property with setter |
| src/greeter/sessionmodel.cpp | Refactored to use member variables instead of private class, proper currentIndex tracking |
| src/greeter/usermodel.h | Renamed LoginedRole to LoggedInRole, logined() to loggedIn(), updated method signatures |
| src/greeter/usermodel.cpp | Updated role names and method implementations for the loggedIn renaming |
| src/greeter/user.h | Renamed logined() to loggedIn() and setLogined() to setLoggedIn() |
| src/greeter/user.cpp | Updated member variable and method implementations for loggedIn renaming |
| src/seat/helper.h | Added m_greeterProxy and m_sessionModel members, inlined userModel() and added sessionModel() accessor |
| src/seat/helper.cpp | Added GreeterProxy and SessionModel singleton initialization, passed GreeterProxy to LockScreen constructor |
| src/core/lockscreen.h | Added GreeterProxy* parameter to constructor and m_greeterProxy member |
| src/core/lockscreen.cpp | Delegates lock/unlock/shutdown/switchUser to GreeterProxy instead of calling QML methods directly |
| src/wallpaper/wallpapercontroller.h | Removed ScaleWithoutAnimation enum value |
| src/wallpaper/wallpapercontroller.cpp | Removed ScaleWithoutAnimation case from switch statement |
| src/plugins/lockscreen/qml/GreeterModel.qml | Deleted QML singleton, functionality moved to C++ GreeterProxy |
| src/plugins/lockscreen/qml/Greeter.qml | Simplified to use GreeterProxy properties, removed CurrentMode enum and start() function |
| src/plugins/lockscreen/qml/LockView.qml | Listens to GreeterProxy.lockChanged signal, removed old GreeterModel state handling |
| src/plugins/lockscreen/qml/UserInput.qml | Uses GreeterProxy directly instead of GreeterModel.proxy, listens to failedAttemptsChanged |
| src/plugins/lockscreen/qml/UserList.qml | Fixed typo: model.logined to model.loggedIn |
| src/plugins/lockscreen/qml/ShutdownView.qml | Uses GreeterProxy directly, removed intermediate signals |
| src/plugins/lockscreen/qml/SessionList.qml | Uses SessionModel.currentIndex directly instead of GreeterModel.currentSession |
| src/plugins/lockscreen/qml/PowerList.qml | Uses GreeterProxy directly, removed lock signal propagation |
| src/plugins/lockscreen/qml/ControlAction.qml | Uses GreeterProxy.hasActiveSession and SessionModel.currentIndex |
| src/plugins/lockscreen/qml/LoginAnimation.qml | Checks GreeterProxy.showAnimation to conditionally run or skip animations |
| src/core/qml/PrimaryOutput.qml | Removed ScaleWithoutAnimation state, uses Behavior with GreeterProxy.showAnimation |
| src/plugins/lockscreen/CMakeLists.txt | Removed GreeterModel.qml from build files |
0430ce3 to
966d80e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/greeter/usermodel.cpp:176
UserModel::updateUserLoginState()computesposincorrectly (std::distance(d->users.end(), user)) and then callsdataChanged(index(0, pos - 1), index(0, pos))with row/column swapped. This can produce invalid model indexes (often negative), so views won’t update correctly.
Suggestion: compute the row as std::distance(d->users.begin(), user) and emit dataChanged(index(row, 0), index(row, 0)) (and avoid emitting layoutChanged() unless the row order/count changes).
UserModel::updateUserLoginState() 的 pos 计算方式有误(使用了 std::distance(d->users.end(), user)),并且 dataChanged(index(0, pos - 1), index(0, pos)) 的行/列参数也写反了,可能导致发出无效索引(甚至为负),从而界面不刷新。
建议:用 std::distance(d->users.begin(), user) 得到 row,并发出 dataChanged(index(row, 0), index(row, 0));除非模型结构变化,否则不要发 layoutChanged()。
void UserModel::updateUserLoginState(const QString &username, bool loggedIn)
{
auto user = std::find_if(d->users.begin(), d->users.end(), [&username](const UserPtr &user) {
return user->userName() == username;
});
if (user != d->users.end()) {
(*user)->setLoggedIn(loggedIn);
auto pos = std::distance(d->users.end(), user);
Q_EMIT dataChanged(index(0, pos - 1), index(0, pos));
}
Q_EMIT layoutChanged();
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: calsys456 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1 similar comment
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: calsys456 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This makes the code more clean, clear and robustic.
Use systemd-logind for lock & unlock is much more portable and robustic.
chore: clean up the logic of greeter and lockscreen
This makes the code more clean, clear and robustic.
feat: listen to the Lock/Unlock signal of org.freedesktop.login1.Session
Use systemd-logind for lock & unlock is much more portable and robustic.
Paired with linuxdeepin/ddm#83